// 开始打印
function startPrint(trId){
	// console.log('打印: ' + trId);
	// 获取id
	var id = trId.split('-')[1];
	// 获取单元格
	var trPrints = document.getElementsByTagName('tr');
	// 获取具体单元格
	var trPrint = trPrints[id];
	// 获取跳转链接
	var tdManage = trPrint.getElementsByClassName('td-manage')[0];
	var tdManageA = tdManage.getElementsByTagName('a')[0];
	var href = tdManageA.getAttribute('href');
	// console.log(href);

	// var absHref = 'http://49.232.159.185:8080/' + href;

	// <iframe marginwidth=0 marginheight=0 width="100%" height=200 src="top.html" frameborder="no" <!--scrolling="no"-->></iframe>
	// 创建iframe, 用于打开新页面
	var div = document.createElement('div');
	var iframe = document.createElement('iframe');
	iframe.setAttribute('marginwidth', 0);
	iframe.setAttribute('marginheight', 0);
	iframe.setAttribute('width', '100%');
	iframe.setAttribute('height', '100%');
	iframe.setAttribute('src', href);
	iframe.setAttribute('frameborder', 'no');
	iframe.setAttribute('scrolling', 'no');
	// 加载完成后执行打印方法
	iframe.onload = function() {
		console.log('详情页加载完成');
		var childWindow = iframe.contentWindow;
		printByInfo(childWindow)
		// childWindow.generatePrinterGraduationCard();
		// generatePrinterHeGeCard(company,birthday,courseName,name)
	}
	div.appendChild(iframe);
	document.body.appendChild(div);
}

// 文件改变
function fileChanged(){
	console.log('文件');
	var inputFile = document.getElementById('inputFile');
	console.log(inputFile);
}

// 先获取信息, 再打印
function printByInfo(childWindow) {
	let childDocument = childWindow.document;
	let tbody = childDocument.getElementsByTagName('tbody')[0];
	let trs = tbody.getElementsByTagName('tr');
	// 姓名
	let name = trs[0].getElementsByTagName('td')[3].innerHTML;
	// console.log(name)
	// 生日
	let birthday = trs[2].getElementsByTagName('td')[3].innerHTML;
	// console.log(birthday)
	// 公司
	let company = trs[3].getElementsByTagName('td')[3].innerHTML;
	// console.log(company)
	// 课程名
	let courseName = trs[5].getElementsByTagName('td')[1].innerHTML;
	// console.log(courseName)
	childWindow.generatePrinterHeGeCard(company,birthday,courseName,name)
}












